package com.community.web.controller.visitor;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.community.body.domain.ZyVisitor;
import com.community.body.dto.VisitorDTO;
import com.community.body.service.IZyVisitorService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.community.common.annotation.Log;
import com.community.common.core.controller.BaseController;
import com.community.common.core.domain.AjaxResult;
import com.community.common.enums.BusinessType;
import com.community.common.utils.poi.ExcelUtil;
import com.community.common.core.page.TableDataInfo;

/**
 * 访客邀请 Controller
 * 
 * @author community
 * @date 2024-04-16
 */
@RestController
@RequestMapping("/visitor/invite")
public class ZyVisitorController extends BaseController
{
    @Autowired
    private IZyVisitorService zyVisitorService;

    /**
     * 查询访客邀请 列表
     */
    @PreAuthorize("@ss.hasPermi('visitor:invite:list')")
    @GetMapping("/list")
    public TableDataInfo list(VisitorDTO visitorDTO)
    {
        startPage();
        List<VisitorDTO> list = zyVisitorService.selectZyVisitorList(visitorDTO);
        return getDataTable(list);
    }

//    /**
//     * 导出访客邀请 列表
//     */
//    @PreAuthorize("@ss.hasPermi('visitor:invite:export')")
//    @Log(title = "访客邀请 ", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, ZyVisitor zyVisitor)
//    {
//        List<ZyVisitor> list = zyVisitorService.selectZyVisitorList(zyVisitor);
//        ExcelUtil<ZyVisitor> util = new ExcelUtil<ZyVisitor>(ZyVisitor.class);
//        util.exportExcel(response, list, "访客邀请 数据");
//    }

    /**
     * 获取访客邀请 详细信息
     */
    @PreAuthorize("@ss.hasPermi('visitor:invite:query')")
    @GetMapping(value = "/{visitorId}")
    public AjaxResult getInfo(@PathVariable("visitorId") Long visitorId)
    {
        return success(zyVisitorService.selectZyVisitorByVisitorId(visitorId));
    }

    /**
     * 新增访客邀请 
     */
    @PreAuthorize("@ss.hasPermi('visitor:invite:add')")
    @Log(title = "访客邀请 ", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ZyVisitor zyVisitor)
    {
        return toAjax(zyVisitorService.insertZyVisitor(zyVisitor));
    }

    /**
     * 修改访客邀请 
     */
    @PreAuthorize("@ss.hasPermi('visitor:invite:edit')")
    @Log(title = "访客邀请 ", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ZyVisitor zyVisitor)
    {
        return toAjax(zyVisitorService.updateZyVisitor(zyVisitor));
    }

    /**
     * 删除访客邀请 
     */
    @PreAuthorize("@ss.hasPermi('visitor:invite:remove')")
    @Log(title = "访客邀请 ", businessType = BusinessType.DELETE)
	@DeleteMapping("/{visitorIds}")
    public AjaxResult remove(@PathVariable Long[] visitorIds)
    {
        return toAjax(zyVisitorService.deleteZyVisitorByVisitorIds(visitorIds));
    }
}
